<?php namespace web\admin\controller;
	use system\model\User;
	class Login{
		public function login(){
			//判断是否为post请求
			if(IS_POST){
				//获取数据
				$username=Q('post.username','');
				$password=Q('post.password','','md5');
				//从数据库中查询
				$mode=new User;
				$userdata=$mode->where('username',$username)->first();
//				p($userdata);die;
				if(!$userdata){
					message('用户不存在');
					
				}
			if($userdata['password']!=$password){
				message('密码不正确');
				
			}
			$_SESSION['id']=$userdata['uid'];
			message('登录成功',U('admin/Entry/index'));
			}
			
			
			View::make();
		}
		
		//退出登录
		public function out(){
		session_unset();
		session_destroy();
		message('退出成功',U('admin/Login/login'));
			
			
		}
		
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	?>